package com.xyy.saas.payment.service.impl;

import com.xyy.saas.payment.dao.mapper.BankPayRecordMapper;
import com.xyy.saas.payment.dao.model.BankPayRecord;
import com.xyy.saas.payment.service.BankPayRecordService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @Author lina
 * @Description
 * @Date 2022/3/10
 **/
@Service
public class BankPayRecordServiceImpl implements BankPayRecordService {
    @Resource
    private BankPayRecordMapper bankPayRecordMapper;
    @Override
    public BankPayRecord queryByPayNo(String payNo) {
        if (StringUtils.isEmpty(payNo)) {
            return null;
        }
        return bankPayRecordMapper.queryByPayNo(payNo);
    }

    @Override
    public BankPayRecord queryByBusinessNo(String businessNo) {
        if (StringUtils.isEmpty(businessNo)) {
            return null;
        }
        return bankPayRecordMapper.queryByBusinessNo(businessNo);
    }

    @Override
    public int save(BankPayRecord bankPayRecord) {
        if (Objects.isNull(bankPayRecord)) {
            return 0;
        }
        return bankPayRecordMapper.insertSelective(bankPayRecord);
    }

    @Override
    public int updateByPayNo(BankPayRecord bankPayRecord) {
        if (Objects.isNull(bankPayRecord)) {
            return 0;
        }
        if (StringUtils.isEmpty(bankPayRecord.getPayNo())) {
            return 0;
        }
        return bankPayRecordMapper.updateByPayNo(bankPayRecord);
    }
}
